home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Data 2002 May / CD Rom Data Mayıs 2002.iso / Freeware / Blitz Basic / data1.cab / Support / help / samples / transition / transition.bb < prev   
Encoding:
Text File  |  2002-04-10  |  2.9 KB  |  75 lines

  1. ; Name:            transition.bb
  2. ; Extra Files:    BlitzLogo.bmp
  3. ; Version:        1.1 (Works with final release version of Blitz)
  4. ; Description:    My 2 cents worth of a wipe/transition effect.
  5. ; Author:        Mikkel L°kke aka. FlameDuck
  6. ; License:        Public Domain
  7. ; Purpose:        To write a flexible wipe/transition that could be applied to anything.
  8.  
  9.  
  10. ; .........................................................
  11. ; : This part initializes all our variables and constants :
  12. ; :.......................................................:
  13. SeedRnd MilliSecs()
  14. Const width=1024,height=768        ; Define the width/height of the effect
  15.  
  16. Graphics width,height            ; And open a screen
  17.  
  18. img=LoadImage("BlitzLogo.bmp")    ; Load the "target" image
  19.  
  20. Const xsize=16                    ; Set the horizontal size of the blocks
  21. Const ysize=16                    ; Set the vertical size of the blocks
  22. Const xdiv=width/xsize            ; Calculate the number of divisions we have along the x axis
  23. Const ydiv=height/ysize            ; Calculate the number of divisions we have along the y axis
  24. Const total=xdiv*ydiv            ; Calculate the total number of tiles
  25. Const frames=25                    ; This tells us across how many frames we want to spread the animation
  26. Const choice=total/frames        ; The number of tiles to draw each frame
  27. Const fps=25                    ; This is how many frames we want displayed each second
  28. Dim matrix(xdiv,ydiv)            ; Define the array used to hold information on which tiles to do each frame
  29.  
  30. ; .............................................
  31. ; : This part generates a random matrix using :
  32. ; : a brute force even distribution algorithm :
  33. ; :...........................................:
  34.  
  35. For ii = 1 To frames                ; For each frame
  36.     For I = 1 To choice            ; Loop a certain number of choices
  37.         Repeat
  38.             x=Rnd(0,xdiv)        ; Get a random x position
  39.             y=Rnd(0,ydiv)        ; Get a random y position
  40.         Until matrix(x,y)=0        ; And if something is allready there, get them again
  41.         matrix(x,y)=ii            ; Otherwise store the frame number
  42.     Next
  43. Next
  44.  
  45. ; ..............................................
  46. ; : This part creates the transition animation :
  47. ; :............................................:
  48.  
  49. dly=CreateTimer(fps)            ; Create a new CPU timer
  50. For frm=0 To frames                ; Loop through each frame
  51.     WaitTimer(dly)                ; Wait for a timer hit
  52.     For x=0 To xdiv                ; Loop through all the x positions
  53.         For y=0 To ydiv            ; And all the y positions
  54.             If matrix(x,y)=frm    ; If this position is to be shown at this frame
  55.                 DrawImageRect img,x*xsize,y*ysize,x*xsize,y*ysize,xsize,ysize    ; Draw it
  56.             End If
  57.         Next
  58.     Next
  59. Next
  60.  
  61. WaitMouse                        ; Wait for the mouse to be pressed
  62.  
  63. Color 0,0,0
  64. For frm=0 To frames                ; Loop through each frame
  65.     WaitTimer(dly)                ; Wait for a timer hit
  66.     For x=0 To xdiv                ; Loop through all the x positions
  67.         For y=0 To ydiv            ; And all the y positions
  68.             If matrix(x,y)=frm    ; If this position is to be shown at this frame
  69.                 Rect x*xsize,y*ysize,xsize,ysize    ; Clear it
  70.             End If
  71.         Next
  72.     Next
  73. Next
  74.  
  75. End                                ; Terminate the program